package com.njupt.controller;

import com.njupt.po.Scoreinfo;
import com.njupt.service.ScoreService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ScoreController {

    @Resource
    private ScoreService scoreService;




    @GetMapping("/newscore")
    public int insertScore(double finalScore){
        Scoreinfo scoreinfo = new Scoreinfo();
        scoreinfo.setFinalScore(finalScore);
        return scoreService.insertScore(scoreinfo);
    }

    @GetMapping("/deletescore")
    public int deleteScore(String id){
        return scoreService.deleteScore(id);
    }

    @GetMapping("/viewscore")
    public List<Scoreinfo> search(@RequestParam(name = "date", required = false) String date,
                                  @RequestParam(name = "name", required = false) String name){


        return scoreService.searchScore(date,name);
    }






}
